import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

// ignore: must_be_immutable
class TotalPokers extends StatefulWidget {
  List<Map> totalPokers;
  final totalPokersSelectItem;

  TotalPokers({Key key, this.totalPokers, this.totalPokersSelectItem})
      : super(key: key);

  @override
  _TotalPokersState createState() => _TotalPokersState();
}

class _TotalPokersState extends State<TotalPokers> {
  @override
  Widget build(BuildContext context) {
    return Container(
      width: ScreenUtil().setWidth(750),
      height: ScreenUtil().setHeight(250),
      alignment: Alignment.center,
      child: GridView.builder(
        padding: EdgeInsets.all(5.0),
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: 7,
            //纵轴间距
            mainAxisSpacing: 5.0,
            //横轴间距
            crossAxisSpacing: 5.0,
            //子组件宽高长度比例
            childAspectRatio: 1.0),
        itemCount: widget.totalPokers.length,
        itemBuilder: (BuildContext context, int index) {
          return Material(
            color: Colors.lightBlueAccent,
            child: InkWell(
              onTap: () {
                widget
                    .totalPokersSelectItem(widget.totalPokers[index]["value"]);
              },
              child: Container(
                width: ScreenUtil().setWidth(120),
                height: ScreenUtil().setHeight(60),
                color: Colors.black26,
                child: Center(
                  child: Text(
                    widget.totalPokers[index]["name"],
                    style: TextStyle(
                      fontSize: 16.0,
                      color: Colors.white,
                      decoration: TextDecoration.none,
                    ),
                  ),
                ),
              ),
            ),
          );
        },
      ),
    );
  }
}
